﻿using Android.Content;
using Android.OS;
using Android.Support.V4.View;
using Android.Widget;
using Com.Amap.Api.Maps2d;
using JWXH.XH.components;
using JWXH.XH.Droid.components;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(GaodeMap), typeof(GaodeMapRender))]
namespace JWXH.XH.Droid.components
{
    public class GaodeMapRender : ViewRenderer
    {
        private Context _context;
        public GaodeMapRender(Context context) : base(context)
        {
            _context = context;
        }

        protected override void OnElementChanged(ElementChangedEventArgs<View> e)
        {
            base.OnElementChanged(e);
            if (Control == null)
            {
                LinearLayout container = new LinearLayout(this._context);
                container.SetMinimumWidth(500);
                container.SetMinimumHeight(500);
                var map = new MapView(this._context);
                map.OnCreate(new Bundle());
                //                map.
                //container.AddView(map);
//                container.AddView(new TextView(this._context)
//                {
//                    Text = "shit123"
//                });
                this.SetNativeControl(container);
//                Control.SetMinimumHeight(500);
//                Control.SetBackgroundColor(Android.Graphics.Color.Red);
            }
            else {
            }
        }
    }
}